package cn.javaxc.mvcwork.modules.file;
import java.io.*;
import org.springframework.web.multipart.MultipartFile;



public class FileInfo implements MultipartFile{
  private String name ,  clientFileName ,  fileContentType ;
  private byte[] fileContents ;
  private File file ;
  private StringBuffer sb = new StringBuffer(100);
  private double version = 0;
  private Object extensionId = 0;
  private long size = -1;
	private String saveFileName;

  
  public void setName(String aName) {
    name = aName;
  }


  
  public void setClientFileName(String aClientFileName) {
    clientFileName = aClientFileName;
  }


  
  public void setLocalFile(File aFile) {
    file = aFile;
  }


  
  public void setFileContents(byte[] aByteArray) {
    fileContents = new byte[aByteArray.length];
    System.arraycopy(aByteArray, 0, fileContents, 0, aByteArray.length);
  }


  
  public void setFileContentType(String aContentType) {
    fileContentType = aContentType;
  }


  
  public void setVersion(double tmp) {
    this.version = tmp;
  }


  
  public void setSize(long tmp) {
    this.size = tmp;
  }


  
  public void setExtensionId(Object tmp) {
    this.extensionId = tmp;
  }


  
  public String getName() {
    return name;
  }


  
  public String getOriginalFilename() {
    return clientFileName;
  }


  
  public String getFilename() {
    return file.getName();
  }


  
  public String getRealFilename() {
    int index = file.getName().lastIndexOf('^');
    if (index >= 0) {
      return (file.getName().substring(0, index));
    } else {
      return (file.getName());
    }
  }


  
  public File getLocalFile() {
    return file;
  }


  
  public byte[] getBytes() {
    return fileContents;
  }

  public InputStream getInputStream(){
	return null;
  }

  
  public String getContentType() {
    return fileContentType;
  }


  
  public double getVersion() {
    return version;
  }


  
  public Object getExtensionId() {
    return extensionId;
  }


  
  public long getSize() {
    return (size);
  }


  
  public String getOldLocalFilePath() {
    int index = file.getPath().lastIndexOf('-');
    if (index >= 0) {
      return (file.getPath().substring(0, index));
    } else {
      return (file.getPath());
    }
  }


  
  public String toString() {
    sb.setLength(0);
    sb.append("               name = " + name + "\n");
    sb.append("     clientFileName = " + clientFileName + "\n");
    if (file != null) {
      sb.append(
          "      File.toString = " + file +
          " (size=" + file.length() + ")\n");
    } else {
      sb.append("fileContents.length = " + fileContents.length + "\n");
    }
    sb.append("            version = " + version + "\n");
    return sb.toString();
  }
	public String getSaveFileName(){
		return this.saveFileName;
	}
	public void setSaveFileName(String saveFileName){
		this.saveFileName=saveFileName;
	}

	public boolean isEmpty(){
		return false;
	}
    public void transferTo(File file){
	
	}
}
